//@ts-check

/**@enum {string} */
export const defaultStatus = Object.freeze({
  WAIT_PAY: "未支付",
  WAIT_RECEIPT: "已接单",
  WAIT_COMMENT: "已送达",
  NOT_RECEIVING: "未接单",
  CANCEL: "已取消",
  FINISH: "已确认",
});

/**@enum {string} */
export const orderStatus = Object.freeze({
  WAIT_PAY: "未支付",
  WAIT_RECEIPT: "已接单",
  WAIT_COMMENT: "已维修",
  NOT_RECEIVING: "未接单",
  CANCEL: "已取消",
  FINISH: "已确认",
});

/**@enum {string} */
export const goodsType = Object.freeze({
  LEASE: "租赁",
  NOT_LEASE: "非租赁",
});

/**@enum {string} */
export const auditType = Object.freeze({
  PASS: "通过",
  NOT_PASS: "不通过",
  WAIT_AUDIT: "待审核",
});

export function enumOptionValue(name) {
  switch (name) {
    case "auditType":
      return enumToOption(auditType);
    case "goodsType":
      return enumToOption(goodsType);
    case "orderStatus":
      return enumToOption(orderStatus);
    case "defaultStatus":
      return enumToOption(defaultStatus);
    default:
      return [];
  }
}

function enumToOption(freeze) {
  const options = [];
  Object.keys(freeze).forEach((key) => {
    options.push({
      value: key,
      label: freeze[key],
    });
  });
  return options;
}
